/* Copyright (c) 2010, Shawn McGregor All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. rgled.c */ #include #include "rgled.h" /****************************************************************** Function: void dled_red (void) void dled_green (void) void dled_off (void) Input: Output: Overview: switch bi LED to red or green illumination, or off ********************************************************************/ void dled_red (void) { dLED1Grn = 1; dLED1Red = 0; return; } void dled_green (void) { dLED1Grn = 0; dLED1Red = 1; return; } void dled_off (void) { dLED1Grn = 0; dLED1Red = 0; return; } /****************************************************************** Function: void dled_code (char value) Input: Output: Overview: blink error code out on led, Green = 1 Red = 0 ********************************************************************/ void dled_code (char value) { char cntpos = 0; dled_green(); // Blink to indicate transmission Delay10KTCYx(250); Delay10KTCYx(250); dled_off(); // Clear color code Delay10KTCYx(250); Delay10KTCYx(250); Delay10KTCYx(250); Delay10KTCYx(250); Delay10KTCYx(250); Delay10KTCYx(250); Delay10KTCYx(250); Delay10KTCYx(250); for (cntpos = 0; cntpos < 8; cntpos++) { if (bitchk (value,cntpos) != 0) { dled_green(); // 1 = Green pulse signal } else { dled_red(); // 0 = Red pulse signal } Delay10KTCYx(250); // Show code signal ~1 second Delay10KTCYx(250); dled_off(); // Off code signal ~1 second Delay10KTCYx(250); Delay10KTCYx(250); } dled_off(); // Delay for end of transmission Delay10KTCYx(250); Delay10KTCYx(250); Delay10KTCYx(250); Delay10KTCYx(250); }